package model;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class TUser {
	private String userid;
	private String nickname;
	private String pwd;
	private int usertype;
	private String realname;
	private int userphoto;
	private String signed;
	private String agend;
	private String birthday;
	private String mobile;
	private String pid;
	private String logintime;
	private String loginaddr;
	private boolean isdelete;
	private int anthority;
	private String createtime;
	private int articlecounter;
	
	public TUser(ResultSet rs)
	{
		try {
			if(rs!=null && rs.next()){
				this.userid = rs.getString("userid");
				this.nickname = rs.getString("nickname");
				this.pwd = rs.getString("pwd");
				this.usertype = rs.getInt("usertype");
				
				this.realname = rs.getString("realname");
				this.userphoto = rs.getInt("userphoto");
				this.signed = rs.getString("signed");
				this.agend = rs.getString("agend");
				this.birthday = rs.getString("birthday");
				this.mobile = rs.getString("mobile");
				this.pid = rs.getString("pid");
				this.logintime = rs.getString("logintime");
				this.loginaddr = rs.getString("loginaddr");
				this.createtime = rs.getString("createtime");
				this.anthority = rs.getInt("anthority");
				this.articlecounter = rs.getInt("articlecounter");
				this.isdelete = rs.getBoolean("isdelete");				
				
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	public static List<TUser> toList(ResultSet rs){
		List<TUser> list = new ArrayList<TUser>();
		if(rs!=null)
		{
			try {
				while (rs.next()) {
					TUser user = new TUser();
				
				
				
				user.userid = rs.getString("userid");
				user.nickname = rs.getString("nickname");
				user.pwd = rs.getString("pwd");
				user.usertype = rs.getInt("usertype");
				
				user.realname = rs.getString("realname");
				user.userphoto = rs.getInt("userphoto");
				user.signed = rs.getString("signed");
				user.agend = rs.getString("agend");
				user.birthday = rs.getString("birthday");
				user.mobile = rs.getString("mobile");
				user.pid = rs.getString("pid");
				user.logintime = rs.getString("logintime");
				user.loginaddr = rs.getString("loginaddr");
				user.createtime = rs.getString("createtime");
				user.anthority = rs.getInt("anthority");
				user.articlecounter = rs.getInt("articlecounter");
				user.isdelete = rs.getBoolean("isdelete");				
				
				list.add(user);
}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		}
		return list;
	}
	public TUser()
	{
		
	}
	public TUser(String userid, String nickname, String pwd, int usertype,
			String realname, int userphoto, String signed, String agend,
			String birthday, String mobile, String pid, String logintime,
			String loginaddr, boolean isdelete, int anthority, String createtime,
			int articlecounter) {
		super();
		this.userid = userid;
		this.nickname = nickname;
		this.pwd = pwd;
		this.usertype = usertype;
		this.realname = realname;
		this.userphoto = userphoto;
		this.signed = signed;
		this.agend = agend;
		this.birthday = birthday;
		this.mobile = mobile;
		this.pid = pid;
		this.logintime = logintime;
		this.loginaddr = loginaddr;
		this.isdelete = isdelete;
		this.anthority = anthority;
		this.createtime = createtime;
		this.articlecounter = articlecounter;
	}
	public String getUserid() {
		return userid;
	}
	public void setUserid(String userid) {
		this.userid = userid;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public int getUsertype() {
		return usertype;
	}
	public void setUsertype(int usertype) {
		this.usertype = usertype;
	}
	public String getRealname() {
		return realname;
	}
	public void setRealname(String realname) {
		this.realname = realname;
	}
	public int getUserphoto() {
		return userphoto;
	}
	public void setUserphoto(int userphoto) {
		this.userphoto = userphoto;
	}
	public String getSigned() {
		return signed;
	}
	public void setSigned(String signed) {
		this.signed = signed;
	}
	public String getAgend() {
		return agend;
	}
	public void setAgend(String agend) {
		this.agend = agend;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getPid() {
		return pid;
	}
	public void setPid(String pid) {
		this.pid = pid;
	}
	public String getLogintime() {
		return logintime;
	}
	public void setLogintime(String logintime) {
		this.logintime = logintime;
	}
	public String getLoginaddr() {
		return loginaddr;
	}
	public void setLoginaddr(String loginaddr) {
		this.loginaddr = loginaddr;
	}
	
	public boolean isIsdelete() {
		return isdelete;
	}
	public void setIsdelete(boolean isdelete) {
		this.isdelete = isdelete;
	}
	public int getAnthority() {
		return anthority;
	}
	public void setAnthority(int anthority) {
		this.anthority = anthority;
	}
	public String getCreatetime() {
		return createtime;
	}
	public void setCreatetime(String createtime) {
		this.createtime = createtime;
	}
	public int getArticlecounter() {
		return articlecounter;
	}
	public void setArticlecounter(int articlecounter) {
		this.articlecounter = articlecounter;
	}
}
